package 设计模式.设计原则.依赖倒置;

public class Test {
    public static void main(String[] args) {
        //接口方法的方式注入具体的实现
        //Study xiaozhao = new Study();
        //xiaozhao.studyCourse(new JavaCourse());
        //xiaozhao.studyCourse(new PythonCourse());

        //构造器注入,缺点是想多次使用需多次构建xiaohong，如在Spring中bean是单例的
        //Study xiaohong = new Study(new JavaCourse());
        //xiaohong.studyCourse();

        //setter方式注入
        Study xiaolan = new Study();
        xiaolan.setCourse(new JavaCourse());
        xiaolan.studyCourse();

    }
}
